
#include <opencv2\core\core.hpp>
#include <opencv2\highgui\highgui.hpp>
#include <opencv2\imgproc\imgproc.hpp>
#include <iostream>
#include "header.h";

using namespace std;  
using namespace cv;  

int main (){


	Mat img, processed; 
	uchar table[256];
	int divideWidth = 0;



	img = imread("C:\\img.jpg", CV_LOAD_IMAGE_COLOR);

	if(!img.data){
		cout<<"ni chuja\n";
		getchar();
		return -1;
	}


	for(int i=0;i<256;i++){
		//table[i] = (uchar) (divideWidth * (i/divideWidth));
		table[i] = (uchar) i & 0x80;
	}

	namedWindow("normal img");
	imshow("normal img" ,img);

	int channels = img.channels();
	int rows = img.rows;
	int cols = img.cols * channels;
	cout << "channels: "<<channels<<" rows: "<<rows<<" cols: "<<cols<<"\n";

	uchar* p;

	

	namedWindow("proccessed img");
	int tmp=0;

	while(divideWidth++<256){
		processed = img.clone();
		for(int r=0;r<rows;r++){

			p = processed.ptr<uchar>(r);
			for(int c=0;c<processed.cols;c++){
				
				tmp = c*3;
				//p[tmp] = (uchar) p[tmp] | divideWidth;
				
				tmp++;
				//p[tmp] = (uchar) p[tmp] | divideWidth;
				
				tmp++;
				p[tmp] = (uchar) p[tmp] | divideWidth;
			}
		}

		
		imshow("proccessed img" ,processed);
		waitKey(20);
	}

	


	 
	




	waitKey(0);
	return 1;
}